<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Freetype OpenGL: demo-ansi.c</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="style.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="content"><!-- do not remove this div! -->

<div id="top"><!-- do not remove this div! -->

  
  <div id="titlearea">
    
    <div id="projectname">Freetype OpenGL</div>
    
    
    <div id="projectbrief">A high quality OpenGL text rendering engine for C</div>
    
  </div>
  

<!--

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Freetype OpenGL
   &#160;<span id="projectnumber">0.1</span>
   </div>
   <div id="projectbrief">A high quality OpenGL text rendering engine for C</div>
  </td>
  
  
  
   
  
 </tr>
 </tbody>
</table>
</div>
-->


<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript" src="dynsections.js"></script>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">demo-ansi.c</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="comment">/* ============================================================================</span>
<span class="comment"> * Freetype GL - A C OpenGL Freetype engine</span>
<span class="comment"> * Platform:    Any</span>
<span class="comment"> * WWW:         http://code.google.com/p/freetype-gl/</span>
<span class="comment"> * ----------------------------------------------------------------------------</span>
<span class="comment"> * Copyright 2011,2012 Nicolas P. Rougier. All rights reserved.</span>
<span class="comment"> *</span>
<span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<span class="comment"> * modification, are permitted provided that the following conditions are met:</span>
<span class="comment"> *</span>
<span class="comment"> *  1. Redistributions of source code must retain the above copyright notice,</span>
<span class="comment"> *     this list of conditions and the following disclaimer.</span>
<span class="comment"> *</span>
<span class="comment"> *  2. Redistributions in binary form must reproduce the above copyright</span>
<span class="comment"> *     notice, this list of conditions and the following disclaimer in the</span>
<span class="comment"> *     documentation and/or other materials provided with the distribution.</span>
<span class="comment"> *</span>
<span class="comment"> * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER &#39;&#39;AS IS&#39;&#39; AND ANY EXPRESS OR</span>
<span class="comment"> * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF</span>
<span class="comment"> * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO</span>
<span class="comment"> * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,</span>
<span class="comment"> * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES</span>
<span class="comment"> * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;</span>
<span class="comment"> * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</span>
<span class="comment"> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span>
<span class="comment"> * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF</span>
<span class="comment"> * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<span class="comment"> *</span>
<span class="comment"> * The views and conclusions contained in the software and documentation are</span>
<span class="comment"> * those of the authors and should not be interpreted as representing official</span>
<span class="comment"> * policies, either expressed or implied, of Nicolas P. Rougier.</span>
<span class="comment"> * ============================================================================</span>
<span class="comment"> */</span>
<span class="preprocessor">#include &quot;freetype-gl.h&quot;</span>

<span class="preprocessor">#include &quot;<a class="code" href="font-manager_8h.html">font-manager.h</a>&quot;</span>
<span class="preprocessor">#include &quot;<a class="code" href="vertex-buffer_8h.html">vertex-buffer.h</a>&quot;</span>
<span class="preprocessor">#include &quot;<a class="code" href="text-buffer_8h.html">text-buffer.h</a>&quot;</span>
<span class="preprocessor">#include &quot;<a class="code" href="markup_8h.html">markup.h</a>&quot;</span>
<span class="preprocessor">#include &quot;<a class="code" href="shader_8h.html">shader.h</a>&quot;</span>


<span class="comment">// ------------------------------------------------------- global variables ---</span>
<a name="_a0"></a><a class="code" href="structtext__buffer__t.html" title="Text buffer structure.">text_buffer_t</a> * text_buffer;




<span class="comment">// ---------------------------------------------------------------- display ---</span>
<span class="keywordtype">void</span> display( <span class="keywordtype">void</span> )
{
    glClearColor(1.00,1.00,1.00,1.00);
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    <a name="a1"></a><a class="code" href="group__text-buffer.html#gadbcccef4916637e046f5b342f195d635" title="Render a text buffer.">text_buffer_render</a>( text_buffer );
    glutSwapBuffers( );
}


<span class="comment">// --------------------------------------------------------------- reshape ---</span>
<span class="keywordtype">void</span> reshape(<span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height)
{
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, width, 0, height, -1, 1);
    glMatrixMode(GL_MODELVIEW);
    glutPostRedisplay();
}


<span class="comment">// --------------------------------------------------------------- keyboard ---</span>
<span class="keywordtype">void</span> keyboard( <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> key, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y )
{
    <span class="keywordflow">if</span> ( key == 27 )
    {
        exit( EXIT_SUCCESS );
    }
}


<span class="comment">// ------------------------------------------------------------ init_colors ---</span>
<span class="keywordtype">void</span>
init_colors( <a name="_a2"></a><a class="code" href="unionvec4.html" title="Tuple of 4 floats.">vec4</a> *colors )
{
    <a class="code" href="unionvec4.html" title="Tuple of 4 floats.">vec4</a> defaults[16] = 
        {
            {{ 46/256.0f,  52/256.0f,  54/256.0f, 1.0f}},
            {{204/256.0f,   0/256.0f,   0/256.0f, 1.0f}},
            {{ 78/256.0f, 154/256.0f,   6/256.0f, 1.0f}},
            {{196/256.0f, 160/256.0f,   0/256.0f, 1.0f}},
            {{ 52/256.0f, 101/256.0f, 164/256.0f, 1.0f}},
            {{117/256.0f,  80/256.0f, 123/256.0f, 1.0f}},
            {{  6/256.0f, 152/256.0f, 154/256.0f, 1.0f}},
            {{211/256.0f, 215/256.0f, 207/256.0f, 1.0f}},
            {{ 85/256.0f,  87/256.0f,  83/256.0f, 1.0f}},
            {{239/256.0f,  41/256.0f,  41/256.0f, 1.0f}},
            {{138/256.0f, 226/256.0f,  52/256.0f, 1.0f}},
            {{252/256.0f, 233/256.0f,  79/256.0f, 1.0f}},
            {{114/256.0f, 159/256.0f, 207/256.0f, 1.0f}},
            {{173/256.0f, 127/256.0f, 168/256.0f, 1.0f}},
            {{ 52/256.0f, 226/256.0f, 226/256.0f, 1.0f}},
            {{238/256.0f, 238/256.0f, 236/256.0f, 1.0f}}
        };
    <span class="keywordtype">size_t</span> i = 0;
    <span class="comment">// Default 16 colors</span>
    <span class="keywordflow">for</span>( i=0; i&lt; 16; ++i )
    {
        colors[i] = defaults[i];
    }
    <span class="comment">// Color cube</span>
    <span class="keywordflow">for</span>( i=0; i&lt;6*6*6; i++ )
    {
        <a class="code" href="unionvec4.html" title="Tuple of 4 floats.">vec4</a> color = {{ (i/6/6)/5.0f, ((i/6)%6)/5.0f, (i%6)/5.0f, 1.0f}};
        colors[i+16] = color;
    }
    <span class="comment">// Grascale ramp (24 tones)</span>
    <span class="keywordflow">for</span>( i=0; i&lt;24; i++ )
    {
        <a class="code" href="unionvec4.html" title="Tuple of 4 floats.">vec4</a> color ={{i/24.0f, i/24.0f, i/24.0f, 1.0f}};
        colors[232+i] = color;
    }
}


<span class="comment">// --------------------------------------------------------- ansi_to_markup ---</span>
<span class="keywordtype">void</span>
ansi_to_markup( <span class="keywordtype">wchar_t</span> *sequence, <span class="keywordtype">size_t</span> length, <a name="_a3"></a><a class="code" href="structmarkup__t.html" title="Simple structure that describes text properties.">markup_t</a> *markup )
{
    <span class="keywordtype">size_t</span> i;
    <span class="keywordtype">int</span> code = 0;
    <span class="keywordtype">int</span> set_bg = -1;
    <span class="keywordtype">int</span> set_fg = -1;
    <a class="code" href="unionvec4.html" title="Tuple of 4 floats.">vec4</a> none = {{0,0,0,0}};
    <span class="keyword">static</span> <a class="code" href="unionvec4.html" title="Tuple of 4 floats.">vec4</a> * colors = 0;

    <span class="keywordflow">if</span>( colors == 0 )
    {
        colors = (<a class="code" href="unionvec4.html" title="Tuple of 4 floats.">vec4</a> *) malloc( <span class="keyword">sizeof</span>(<a class="code" href="unionvec4.html" title="Tuple of 4 floats.">vec4</a>) * 256 );
        init_colors( colors );
    }

    <span class="keywordflow">if</span>( length &lt;= 1 )
    {
        markup-&gt;<a name="a4"></a><a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a> = colors[0];
        markup-&gt;<a name="a5"></a><a class="code" href="structmarkup__t.html#a1a14c4fb87e2224381288a24f56526c8" title="Underline color.">underline_color</a> = markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a>;
        markup-&gt;<a name="a6"></a><a class="code" href="structmarkup__t.html#a0ed25bfa8bc6ead84ae5c0e31dadc780" title="Overline color.">overline_color</a> = markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a>;
        markup-&gt;<a name="a7"></a><a class="code" href="structmarkup__t.html#a29192ea5e970414c0f2b6596e04b822c" title="Strikethrough color.">strikethrough_color</a> = markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a>;
        markup-&gt;<a name="a8"></a><a class="code" href="structmarkup__t.html#a9a648ea55728ce5555753c0b0c0dc6a8" title="Outline color.">outline_color</a> = markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a>;
        markup-&gt;<a name="a9"></a><a class="code" href="structmarkup__t.html#a188c090aade110f71252dd3f28a4b9c7" title="Background color.">background_color</a> = none;
        markup-&gt;<a name="a10"></a><a class="code" href="structmarkup__t.html#a84af8287dddba1d14190dd33f76af955" title="Whether underline is active.">underline</a> = 0;
        markup-&gt;<a name="a11"></a><a class="code" href="structmarkup__t.html#a678b7a967e3d8bf13400ed72216f7f88" title="Whether overline is active.">overline</a> = 0;
        markup-&gt;<a name="a12"></a><a class="code" href="structmarkup__t.html#a2f3767ea0ddd6e83154daad12cc4d2d0" title="Whether text is bold.">bold</a> = 0;
        markup-&gt;<a name="a13"></a><a class="code" href="structmarkup__t.html#a343eab20b2c5cb225e4b9969bd034642" title="Whether text is italic.">italic</a> = 0;
        markup-&gt;<a name="a14"></a><a class="code" href="structmarkup__t.html#a78e8996a06c5bce517be27cf7339c97c" title="Whether strikethrough is active.">strikethrough</a> = 0;
        <span class="keywordflow">return</span>;
    }

    <span class="keywordflow">for</span>( i=0; i&lt;length; ++i)
    {
        <span class="keywordtype">wchar_t</span> c = *(sequence+i);
        <span class="keywordflow">if</span>( c &gt;= <span class="charliteral">&#39;0&#39;</span> &amp;&amp; c &lt;= <span class="charliteral">&#39;9&#39;</span> )
        {
            code = code * 10 + (c-<span class="charliteral">&#39;0&#39;</span>);
        }
        <span class="keywordflow">else</span> <span class="keywordflow">if</span>( (c == <span class="charliteral">&#39;;&#39;</span>) || (i == (length-1)) )
        {
            <span class="keywordflow">if</span>( set_fg == 1 )
            {
                markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a> = colors[code];
                set_fg = -1;
            }
            <span class="keywordflow">else</span> <span class="keywordflow">if</span>( set_bg == 1 )
            {
                markup-&gt;<a class="code" href="structmarkup__t.html#a188c090aade110f71252dd3f28a4b9c7" title="Background color.">background_color</a> = colors[code];
                set_bg = -1;
            }
            <span class="keywordflow">else</span> <span class="keywordflow">if</span>( (set_fg == 0) &amp;&amp; (code == 5) )
            {
                set_fg = 1;
                code = 0;
            }
            <span class="keywordflow">else</span> <span class="keywordflow">if</span>( (set_bg == 0) &amp;&amp; (code == 5) )
            {
                set_bg = 1;
                code = 0;
            }
            <span class="comment">// Set fg color (30 + x, where x is the index of the color)</span>
            <span class="keywordflow">else</span> <span class="keywordflow">if</span>( (code &gt;= 30) &amp;&amp; (code &lt; 38 ) )
            {
                markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a> = colors[code-30];
            }
            <span class="comment">// Set bg color (40 + x, where x is the index of the color)</span>
            <span class="keywordflow">else</span> <span class="keywordflow">if</span>( (code &gt;= 40) &amp;&amp; (code &lt; 48 ) )
            {
                markup-&gt;<a class="code" href="structmarkup__t.html#a188c090aade110f71252dd3f28a4b9c7" title="Background color.">background_color</a> = colors[code-40];
            }
            <span class="keywordflow">else</span> 
            {
                <span class="keywordflow">switch</span> (code)
                {
                <span class="keywordflow">case</span> 0:
                    markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a> = colors[0];
                    markup-&gt;<a class="code" href="structmarkup__t.html#a188c090aade110f71252dd3f28a4b9c7" title="Background color.">background_color</a> = none;
                    markup-&gt;<a class="code" href="structmarkup__t.html#a84af8287dddba1d14190dd33f76af955" title="Whether underline is active.">underline</a> = 0;
                    markup-&gt;<a class="code" href="structmarkup__t.html#a678b7a967e3d8bf13400ed72216f7f88" title="Whether overline is active.">overline</a> = 0;
                    markup-&gt;<a class="code" href="structmarkup__t.html#a2f3767ea0ddd6e83154daad12cc4d2d0" title="Whether text is bold.">bold</a> = 0;
                    markup-&gt;<a class="code" href="structmarkup__t.html#a343eab20b2c5cb225e4b9969bd034642" title="Whether text is italic.">italic</a> = 0;
                    markup-&gt;<a class="code" href="structmarkup__t.html#a78e8996a06c5bce517be27cf7339c97c" title="Whether strikethrough is active.">strikethrough</a> = 0;
                    <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 1: markup-&gt;<a class="code" href="structmarkup__t.html#a2f3767ea0ddd6e83154daad12cc4d2d0" title="Whether text is bold.">bold</a> = 1; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 21: markup-&gt;<a class="code" href="structmarkup__t.html#a2f3767ea0ddd6e83154daad12cc4d2d0" title="Whether text is bold.">bold</a> = 0; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 2: markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a>.<a name="a15"></a><a class="code" href="unionvec4.html#ad5ffee1a120a0856cdab9c03882a7401" title="Alias fo fourth component.">alpha</a> = 0.5; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 22: markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a>.<a class="code" href="unionvec4.html#ad5ffee1a120a0856cdab9c03882a7401" title="Alias fo fourth component.">alpha</a> = 1.0; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 3:  markup-&gt;<a class="code" href="structmarkup__t.html#a343eab20b2c5cb225e4b9969bd034642" title="Whether text is italic.">italic</a> = 1; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 23: markup-&gt;<a class="code" href="structmarkup__t.html#a343eab20b2c5cb225e4b9969bd034642" title="Whether text is italic.">italic</a> = 0; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 4:  markup-&gt;<a class="code" href="structmarkup__t.html#a84af8287dddba1d14190dd33f76af955" title="Whether underline is active.">underline</a> = 1; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 24: markup-&gt;<a class="code" href="structmarkup__t.html#a84af8287dddba1d14190dd33f76af955" title="Whether underline is active.">underline</a> = 0; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 8: markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a>.<a class="code" href="unionvec4.html#ad5ffee1a120a0856cdab9c03882a7401" title="Alias fo fourth component.">alpha</a> = 0.0; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 28: markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a>.<a class="code" href="unionvec4.html#ad5ffee1a120a0856cdab9c03882a7401" title="Alias fo fourth component.">alpha</a> = 1.0; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 9:  markup-&gt;<a class="code" href="structmarkup__t.html#a78e8996a06c5bce517be27cf7339c97c" title="Whether strikethrough is active.">strikethrough</a> = 1; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 29: markup-&gt;<a class="code" href="structmarkup__t.html#a78e8996a06c5bce517be27cf7339c97c" title="Whether strikethrough is active.">strikethrough</a> = 0; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 53: markup-&gt;<a class="code" href="structmarkup__t.html#a678b7a967e3d8bf13400ed72216f7f88" title="Whether overline is active.">overline</a> = 1; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 55: markup-&gt;<a class="code" href="structmarkup__t.html#a678b7a967e3d8bf13400ed72216f7f88" title="Whether overline is active.">overline</a> = 0; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 39: markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a> = colors[0]; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 49: markup-&gt;<a class="code" href="structmarkup__t.html#a188c090aade110f71252dd3f28a4b9c7" title="Background color.">background_color</a> = none; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 38: set_fg = 0; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 48: set_bg = 0; <span class="keywordflow">break</span>;
                <span class="keywordflow">default</span>: <span class="keywordflow">break</span>;
                }
            }
            code = 0;
        }
    }
    markup-&gt;<a class="code" href="structmarkup__t.html#a1a14c4fb87e2224381288a24f56526c8" title="Underline color.">underline_color</a> = markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a>;
    markup-&gt;<a class="code" href="structmarkup__t.html#a0ed25bfa8bc6ead84ae5c0e31dadc780" title="Overline color.">overline_color</a> = markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a>;
    markup-&gt;<a class="code" href="structmarkup__t.html#a29192ea5e970414c0f2b6596e04b822c" title="Strikethrough color.">strikethrough_color</a> = markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a>;
    markup-&gt;<a class="code" href="structmarkup__t.html#a9a648ea55728ce5555753c0b0c0dc6a8" title="Outline color.">outline_color</a> = markup-&gt;<a class="code" href="structmarkup__t.html#a04c930fd29432569aee47e56b59e3d79" title="Text color.">foreground_color</a>;
}

<span class="comment">// ------------------------------------------------------------------ print ---</span>
<span class="keywordtype">void</span>
print( <a class="code" href="structtext__buffer__t.html" title="Text buffer structure.">text_buffer_t</a> * buffer, <a name="_a16"></a><a class="code" href="unionvec2.html" title="Tuple of 2 floats.">vec2</a> * pen,
       <span class="keywordtype">wchar_t</span> *text, <a class="code" href="structmarkup__t.html" title="Simple structure that describes text properties.">markup_t</a> *markup )
{
    <span class="keywordtype">wchar_t</span> *seq_start = text, *seq_end = text;
    <span class="keywordtype">wchar_t</span> *p;
    <span class="keywordflow">for</span>( p=text; p&lt;(text+wcslen(text)); ++p )
    {
        <span class="keywordtype">wchar_t</span> *start = wcsstr( p, L<span class="stringliteral">&quot;\033[&quot;</span> );
        <span class="keywordtype">wchar_t</span> *end = NULL;
        <span class="keywordflow">if</span>( start) 
        {
            end = wcsstr( start+1, L<span class="stringliteral">&quot;m&quot;</span>);
        }
        <span class="keywordflow">if</span>( (start == p) &amp;&amp; (end &gt; start) )
        {
            seq_start = start+2;
            seq_end = end;
            p = end;
        }
        <span class="keywordflow">else</span>
        {
            <span class="keywordtype">int</span> seq_size = (seq_end-seq_start)+1;
            <span class="keywordtype">wchar_t</span> * text_start = p;
            <span class="keywordtype">int</span> text_size = 0;
            <span class="keywordflow">if</span>( start )
            {
                text_size = start-p;
                p = start-1;
            }
            <span class="keywordflow">else</span>
            {
                text_size = text+wcslen(text)-p;
                p = text+wcslen(text);
            }                
            ansi_to_markup(seq_start, seq_size, markup );
            markup-&gt;<a name="a17"></a><a class="code" href="structmarkup__t.html#a5c61d3d8f7da003b885a413780240318" title="Pointer on the corresponding font (family/size/bold/italic)">font</a> = <a name="a18"></a><a class="code" href="group__font-manager.html#gaab7e279a33054137e359e450e2806970" title="Request for a font based on a markup.">font_manager_get_from_markup</a>( text_buffer-&gt;<a name="a19"></a><a class="code" href="structtext__buffer__t.html#a7d9ae1107c2046a5a37fa0000c2fa10f" title="Font manager.">manager</a>, markup );
            <a name="a20"></a><a class="code" href="group__text-buffer.html#ga7d8bb02091e52fb172209510fef2f036" title="Add some text to the text buffer.">text_buffer_add_text</a>( text_buffer, pen, markup, text_start, text_size );
        }
    }
}


<span class="comment">// ------------------------------------------------------------------- main ---</span>
<span class="keywordtype">int</span> main( <span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv )
{
    glutInit( &amp;argc, argv );
    glutInitWindowSize( 800, 500 );
    glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
    glutCreateWindow( argv[0] );
    glutReshapeFunc( reshape );
    glutDisplayFunc( display );
    glutKeyboardFunc( keyboard );

    text_buffer = <a name="a21"></a><a class="code" href="group__text-buffer.html#gad40995db39664d6d3f9da68d386a99da" title="Creates a new empty text buffer.">text_buffer_new</a>( <a name="a22"></a><a class="code" href="text-buffer_8h.html#aeb06e08fcb145b25caf33204ae04c7b7" title="Use LCD filtering.">LCD_FILTERING_ON</a> );
    <a class="code" href="unionvec4.html" title="Tuple of 4 floats.">vec4</a> black = {{0.0, 0.0, 0.0, 1.0}};
    <a class="code" href="unionvec4.html" title="Tuple of 4 floats.">vec4</a> none  = {{1.0, 1.0, 1.0, 0.0}};
    <a class="code" href="structmarkup__t.html" title="Simple structure that describes text properties.">markup_t</a> markup = {
        .<a name="a23"></a><a class="code" href="structmarkup__t.html#adcb67782935faf6178ef7afde350ca2a" title="A font family name such as &quot;normal&quot;, &quot;sans&quot;, &quot;serif&quot; or &quot;monospace&quot;.">family</a>  = <span class="stringliteral">&quot;fonts/VeraMono.ttf&quot;</span>,
        .size    = 15.0, .bold    = 0,   .italic  = 0,
        .rise    = 0.0,  .spacing = 0.0, .gamma   = 1.0,
        .foreground_color    = black, .background_color    = none,
        .underline           = 0,     .underline_color     = black,
        .overline            = 0,     .overline_color      = black,
        .strikethrough       = 0,     .strikethrough_color = black,
        .font = 0,
    };

    <a class="code" href="unionvec2.html" title="Tuple of 2 floats.">vec2</a> pen = {{10.0, 480.0}};
    FILE *file = fopen ( <span class="stringliteral">&quot;data/256colors.txt&quot;</span>, <span class="stringliteral">&quot;r&quot;</span> );
    <span class="keywordflow">if</span> ( file != NULL )
    {
        <span class="keywordtype">wchar_t</span> line[1024];
        <span class="keywordflow">while</span>( fgetws ( line, <span class="keyword">sizeof</span>(line), file ) != NULL )
        {
            print( text_buffer, &amp;pen, line, &amp;markup );
        }
        fclose ( file );
    }

    glutMainLoop( );
    <span class="keywordflow">return</span> 0;
}
</pre></div> </div><!-- contents -->
</div>
</body>
</html>
